﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Combobox
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            ImageList img = new ImageList();
            img.Images.Add(Image.FromFile(System.IO.Path.GetDirectoryName(Application.StartupPath) + @"\..\image\rasp.png"));
            img.Images.Add(Image.FromFile(System.IO.Path.GetDirectoryName(Application.StartupPath) + @"\..\image\vanlla.png"));
            img.Images.Add(Image.FromFile(System.IO.Path.GetDirectoryName(Application.StartupPath) + @"\..\image\choco.png"));
            img.Images.Add(Image.FromFile(System.IO.Path.GetDirectoryName(Application.StartupPath) + @"\..\image\banana.png"));
            GrapeCity.Win.Spread.InputMan.CellType.GcComboBoxCellType gccombo = new GrapeCity.Win.Spread.InputMan.CellType.GcComboBoxCellType();
            gccombo.DropDownStyle = ComboBoxStyle.DropDownList;
            gccombo.Items.AddRange(new String[] { "Raspberry", "Vanilla", "Chocolate", "Banana" });
            gccombo.Items[0].BackColor = Color.Fuchsia;
            gccombo.Items[1].BackColor = Color.Ivory;
            gccombo.Items[2].BackColor = Color.Chocolate;
            gccombo.Items[3].BackColor = Color.LightYellow;
            gccombo.ImageList = img;
            gccombo.Items[0].Image = 0;
            gccombo.Items[1].Image = 1;
            gccombo.Items[2].Image = 2;
            gccombo.Items[3].Image = 3;
            gccombo.ShowListBoxImage = true;
            gccombo.ImageAlign = HorizontalAlignment.Right;
            gccombo.ListSelectedItemStyle.BackColor = Color.Bisque;
            gccombo.ListSelectedItemStyle.ForeColor = Color.Black;
            fpSpread1.Sheets[0].Cells[1, 1].CellType = gccombo;
            FarPoint.Win.Spread.CellType.CurrencyCellType currencycell = new FarPoint.Win.Spread.CellType.CurrencyCellType();
            fpSpread1.Sheets[0].Cells[1, 2].CellType = currencycell;
            fpSpread1.Sheets[0].Cells[0, 1].Text = "Select a flavor";
            fpSpread1.Sheets[0].Cells[0, 2].Text = "Total";
            fpSpread1.Sheets[0].Columns[1, 2].Font = new Font("Calibri", 10, FontStyle.Bold);
            fpSpread1.Sheets[0].Columns[1, 2].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;
            fpSpread1.Sheets[0].Rows[1].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center;

            fpSpread1.ComboSelChange += fpSpread1_ComboSelChange;
        }

        private void fpSpread1_ComboSelChange(object sender, FarPoint.Win.Spread.EditorNotifyEventArgs e)
        {
            string caseSwitch;
            caseSwitch = fpSpread1.Sheets[0].Cells[1, 1].Text;
            switch (caseSwitch)
            {
                case "Raspberry":
                    fpSpread1.Sheets[0].Cells[1, 2].Value = 5.00;
                    break;
                case "Vanilla":
                    fpSpread1.Sheets[0].Cells[1, 2].Value = 4.00;
                    break;
                case "Chocolate":
                    fpSpread1.Sheets[0].Cells[1, 2].Value = 4.25;
                    break;
                case "Banana":
                    fpSpread1.Sheets[0].Cells[1, 2].Value = 4.75;
                    break;
            }
        }
    }
}
